﻿@using CRM.Admin.Areas.Customer.Controllers
@{
    ViewBag.Title = "VarietyAdd";
}
@model CRM.Admin.Contracts.Dto.Customer.VarietyDto
@section head
{
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.min.js")"></script>
<script type="text/javascript" src="@Url.Content("~/Scripts/jquery.validate.extended.js")"></script>
<script src="@Url.Content("~/ScriptPlugin/WdatePicker/js/WdatePicker.js")"></script>
    <script type="text/javascript" src="@Url.Content("~/Scripts/form2json.js")"></script>
    <script type="text/javascript">
        function SaveData(index) {
            if ($("#productForm").valid())
            {
                var dto = $('#productForm').serializeJson();
                K.AjaxJson("@Url.Content("~/Customer/Variety/VarietyInsert")", dto, function (result) {
                    parent.K.layer.callback(index, result, dto);
                    parent.K.layer.close(index);
                });
            }
        }
    </script>
}
<form action="" id="productForm" name="productForm">
    <div class="content-form">
        <table class="content-table">
            <tr>
                <th>需求类别</th>
                <td>
                    <input type="hidden" id="CustomerId" name="CustomerId" value="@ViewBag.CustomerId" />
                    <input type="hidden" id="Id" name="Id" value="@Guid.NewGuid()" />
                    <select id="DemandType" name="DemandType" onchange="setType()">
                        <option value="0">产品</option>
                        <option value="1">零件</option>
                    </select>
                </td>
                <th>
                    <span id="typetd">顾客产品名称</span>
                </th>
                <td>
                    <div id="Varietypannel">
                        <input type="text" data-valid="required" readonly="readonly" id="DemandSourcesName" name="DemandSourcesName" onclick="GetBreed()" class="p-icon-right p-icon-customer" value="@Model.DemandSourcesName"/>
                    </div>
                    <input type="hidden" id="DemandSourcesId" name="DemandSourcesId" value="@Model.DemandSourcesId"/>
                </td>
            </tr>
            <tr>
                <th>
                    需求年份
                </th>
                <td>
                    <select id="ParticularYear" name="ParticularYear" >
                        @{

                            for (int i = 2014; i < 2024; i++)
                            {
                                <option value="@i" @string.Format("{0}", Model.ParticularYear == i? "selected" : "")>@i 年</option>
                            }
                        }
                       
                        
                    </select>
                </td>
                <th>
                    需求月份
                </th>
                <td>
                    <select id="Month" name="Month">
                        @{
                            for (int i = 1; i < 13; i++)
                            {
                                <option value="@i" @string.Format("{0}", Model.Month == i ? "selected" : "")>@i 月</option>
                            }

                        }
                        <option value="13" @string.Format("{0}",Model.Month==13?"selected":"")>汇总年需求</option>
                      
                        
                    </select>
                </td>
            </tr>
            <tr>
                <th>
                    所用原料材质/牌号
                </th>
                <td>
                    <input type="text" id="MaterialMade" name="MaterialMade" value="@Model.MaterialMade"/>
                </td>
                <th>
                    所用原料规格
                </th>
                <td>
                    <input type="text" id="MaterialSpecs" name="MaterialSpecs" value="@Model.MaterialSpecs"/>
                </td>
            </tr>
            <tr>
                <th>
                    原料单件重量
                </th>
                <td>
                    <input type="text" id="MaterialWeight" name="MaterialWeight" data-rule-number="true" value="@Model.MaterialWeight"/>
                </td>
                <th>
                    当月需求量
                </th>
                <td>
                    <input type="text" id="NowNeedWeight" name="NowNeedWeight" data-rule-number="true" value="@Model.NowNeedWeight"/>
                </td>
            </tr>
            <tr>
                <th>
                    原料单件高度
                </th>
                <td>
                    <input type="text" id="MaterialHeight" name="MaterialHeight" data-rule-number="true" value="@Model.MaterialHeight" />
                </td>
                <th>
                    原料单件厚度
                </th>
                <td>
                    <input type="text" id="MaterialThickness" name="MaterialThickness"  value="@Model.MaterialThickness" />
                </td>
            </tr>
            <tr>
                <th>
                    原料单件宽度
                </th>
                <td>
                    <input type="text" id="MaterialWidth" name="MaterialWidth" data-rule-number="true" value="@Model.MaterialWidth" />
                </td>
                <th>
                    用材收集人
                </th>
                <td>
                    <input type="text" id="GetMaterialUser" name="GetMaterialUser" value="@Model.GetMaterialUser" />
                </td>
            </tr>
            <tr>
                <th><span>对应攀钢品种</span></th>
                <td>
                    <input type="text"  id="BreedName" name="BreedName" readonly="readonly" class="p-icon-right p-icon-customer" onclick="GetDictionary()" value="@Model.BreedName"/>
                    <input type="hidden" id="BreedId" name="BreedId" value="@Model.BreedId"/>
                </td>
                <th>技术、质量要求</th>
                <td>
                    <input type="text" id="QualityProfiles" name="QualityProfiles" value="@Model.QualityProfiles"/>
                </td>
            </tr>
            <tr>
                <th>
                    攀钢钒可覆盖量
                </th>
                <td>
                    <input type="text" id="PGFCoverWeight" name="PGFCoverWeight" data-rule-number="true" value="@Model.PGCoverWeight"/>
                </td>
                <th>
                    <span>攀钢钒已供应量</span>
                </th>
                <td>
                    <input type="text" id="PGFAlreadySupplyWeight" name="PGFAlreadySupplyWeight" data-valid="required"  data-rule-number="true" value="@Model.PGFAlreadySupplyWeight" />
                </td>
            </tr>
            <tr>
                <th>
                    西钢钒可覆盖量
                </th>
                <td>
                    <input type="text" id="XGFCoverWeight" name="XGFCoverWeight" data-rule-number="true" value="@Model.XGFCoverWeight"/>
                </td>
                <th>
                   <span>西钢钒已供应量</span>
                </th>
                <td>
                    <input type="text" id="XGFAlreadySupplyWeight" name="XGFAlreadySupplyWeight" data-valid="required"  data-rule-number="true" value="@Model.XGFAlreadySupplyWeight" />
                </td>
            </tr>
            <tr>
                <th>
                    攀钢可覆盖量
                </th>
                <td>
                    <input type="text" id="PGCoverWeight" name="PGCoverWeight" data-rule-number="true" value="@Model.PGCoverWeight" />
                </td>
                <th>
                    <span>攀钢已供应量</span>
                </th>
                <td>
                    <input type="text" id="PGAlreadySupplyWeight" name="PGAlreadySupplyWeight" data-rule-number="true" value="@Model.PGAlreadySupplyWeight" />
                </td>
            </tr>
            <tr>
                <th>
                    新产品需求
                </th>
                <td>
                    <input type="text" id="NewProductProfiles" name="NewProductProfiles" value="@Model.NewProductProfiles"/>
                </td>
                <th>
                    发展规划
                </th>
                <td>
                    <input type="text" id="DevelopmentProfiles" name="DevelopmentProfiles" value="@Model.DevelopmentProfiles"/>
                </td>
            </tr>

            <tr>
                <th>
                    新顾客要求
                </th>
                <td>
                    <input type="text" id="NewUserProfiles" name="NewUserProfiles" value="@Model.NewUserProfiles"/>
                </td>
                <th>
                    销售可行性分析
                </th>
                <td>
                    <input type="text" id="SaleFeasibility" name="SaleFeasibility" value="@Model.SaleFeasibility"/>
                </td>
            </tr>

            <tr>
                <th>
                    攀钢不能满足供货条件原因
                </th>
                <td>
                    <input type="text" id="NoCooperateProfiles" name="NoCooperateProfiles" value="@Model.NoCooperateProfiles"/>
                </td>
                <th>
                    顾客对产品、价格及与钢厂合作的评价
                </th>
                <td>
                    <input type="text" id="PriceMoreEvaluate" name="PriceMoreEvaluate" value="@Model.PriceMoreEvaluate"/>
                </td>
            </tr>

            <tr>
                <th>
                    目前厂商供货方式
                </th>
                <td>
                    <input type="text" id="NowSupply" name="NowSupply" value="@Model.NowSupply"/>
                </td>
                <th>
                    顾客当月需求计划
                </th>
                <td>
                    <input type="text" id="YearNeedProfiles" name="YearNeedProfiles" value="@Model.NextYearNeedProfiles"/>
                </td>
            </tr>
            <tr>
                <th>
                    顾客次月需求计划
                </th>
                <td>
                    <input type="text" id="NextYearNeedProfiles" name="NextYearNeedProfiles" value="@Model.NextYearNeedProfiles"/>
                </td>
                <th>
                    顾客未来发展规划
                </th>
                <td>
                    <input type="text" id="NextNeedProfiles" name="NextNeedProfiles" value="@Model.NextNeedProfiles"/>
                </td>
            </tr>

            <tr>
                <th>
                    用材档案
                </th>
                <td>
                    <input type="text" id="MaterialProfiles" name="MaterialProfiles" value="@Model.MaterialProfiles"/>
                </td>
                <th>
                    用材收集日期
                </th>
                <td>
                    <input type="text" id="GetMaterialDate" name="GetMaterialDate" readonly="readonly" class="p-icon-date p-icon-right" value="@Model.GetMaterialDate"/>
                </td>
            </tr>

         
        </table>
    </div>
</form>
@section foot
{
    <script type="text/javascript">
        function GetBreed() {
            var urlProduct = "@Url.Content("~/Customer/Product/ProductCheck")";
            var urlComponent = "@Url.Content("~/Customer/Product/ComponentCheck")";
            var urlNow = urlProduct;
            var val = $("#DemandType").val();
            if (val == "0") {
                urlNow = urlProduct;
            } else {
                urlNow = urlComponent;
            }

            K.layer.iframe({
                title: "@Html.GetLayerTitle(LayerIcon.Add, "选择产品或零件")",
                content: urlNow,
                maxmin: true,
                area: ["80%", "80%"],
                callback: function(rows) {
                    if(rows && rows.length > 0)
                    {
                        $("#DemandSourcesName").val(rows[0].Name);
                        $("#DemandSourcesId").val(rows[0].Id);
                    }
                }
            });
        }

        function GetDictionary() {
            K.layer.iframe({
                title: "@Html.GetLayerTitle(LayerIcon.Add, "选择攀钢钢材品种")",
                content: "@Url.Content("~/Sys/Dictionary/DictionaryCheck")?TypeCode=@CustomerInfoController.DicCatalogType.GCPZ",
                maxmin: true,
                area: ["80%", "80%"],
                callback: function(rows) {
                    if(rows && rows.length > 0)
                    {
                        $("#BreedName").val(rows[0].Name);
                        $("#BreedId").val(rows[0].Id);
                    }
                }
            });
        }
        function setType() {
            var val = $("#DemandType").val();
            if (val == "0") {
                $("#typetd").html("顾客产品名称");
            } else {
                $("#typetd").html("顾客零件名称");
            }

            $("#DemandSourcesName").val("");
            $("#DemandSourcesId").val("");
        }
</script>
}